import { useState } from 'react';
import { history } from '@umijs/max';
import { column } from '../service';

const columnData = () => {
  const [columnItem, setColumn] = useState(null);
  const [columnLoading, setLoading] = useState(true);
  const fetchColumn = async (word: string) => {
    setLoading(true);
    try {
      const response = await column({word});
			if(response.error){
				history.push('/404'); // 跳转到 404 页面
			}
      setColumn(response.data);
    } catch (error) {
      //history.push('/404'); // 跳转到 404 页面
      console.error('Failed to fetch banner:', error);
    } finally {
      setLoading(false);
    }
  };

  return {
    columnItem,
    columnLoading,
    fetchColumn,
  };
};
export default columnData;
